{include file="header"}
<div style="padding: 20px;">
<form class="layui-form layui-form-pane" action="">
   <div class="layui-tab-item layui-show">
   	<div class="layui-col-md4">
  <div class="layui-form-item">
    <label class="layui-form-label">上级栏目</label>
    <div class="layui-input-block">
      <select name="tid" lay-verify="required" id="provid">
        <option value=""></option>
        {foreach name=":fun_S('cate',array('open'=>1,'tid'=>0),'px desc','1000',1)" item="v" key="k"}
        <option value="{$v.id}"  {if condition="$v['model'] neq $id"}disabled=""{/if}>{$v.name}</option>
        {volist name=":fun_s('cate',array('open'=>1,'tid'=>$v['id']),'px desc',100,1)" id="vo"}
        <option value="{$vo.id}" {if condition="$vo['model'] neq $id"}disabled=""{/if}>——{$vo.name}</option>
        {/volist}  
        {/foreach} 
      </select>
    </div>
  </div> 
  </div>

   <div class="layui-col-md9">
  <div class="layui-form-item">
    <label class="layui-form-label">标题</label>
    <div class="layui-input-block">
      <input type="text" name="title" value="" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
    </div>
  </div>
 </div>
   <div class="layui-form-item">
       <div class="layui-col-md4">
      <label class="layui-form-label">封面图</label>
    <div class="layui-input-block">
     <input type="text" name="pic" value="" id="upsimg" placeholder="留空自动显示编辑器首张图片" autocomplete="off" class="layui-input">
     </div>
     {:h('adminhtmladda')}
     </div> 
     <div class="layui-col-md1">
     	<button type="button" class="layui-btn layui-btn-normal layui-btn-fluid" id="upimg"><i class="layui-icon">&#xe64a;</i>上传</button>
     </div>
   </div>

    <div class="layui-col-md4">
    <div class="layui-form-item">
    <label class="layui-form-label">是否显示</label>
    <div class="layui-input-block">
      <input type="radio" name="open" value="1" title="正常" checked>
      <input type="radio" name="open" value="0" title="待审">
      <input type="radio" name="open" value="2" title="不通过">
      <input type="radio" name="open" value="-1" title="关闭">
    </div>
    </div>
    </div>
    <div class="layui-col-md3">
    <div class="layui-form-item">
    <label class="layui-form-label">是否置顶</label>
    <div class="layui-input-block">
      <input type="radio" name="settop" value="1" title="开始">
      <input type="radio" name="settop" value="0" title="关闭" checked>
    </div>
    </div>
    </div>
    <div class="layui-col-md3">
    <div class="layui-form-item">
    <label class="layui-form-label">幻灯片</label>
    <div class="layui-input-block">
      <input type="radio" name="slide" value="1" title="开始">
      <input type="radio" name="slide" value="0" title="关闭" checked>
    </div>
    </div>
   </div>
   	<div class="layui-form-item">
    <div class="layui-col-md2">
    <label class="layui-form-label">浏览量</label>
    <div class="layui-input-block">
      <input type="number"  name="view" required  lay-verify="required" value="1"  placeholder="浏览量" autocomplete="off" class="layui-input">
    </div>
    </div>
    </div>
   	<div class="layui-form-item">
    <div class="layui-col-md2">
    <label class="layui-form-label">作者UID</label>
    <div class="layui-input-block">
      <input type="number"  name="uid" required  lay-verify="required" value="1"  placeholder="uid" autocomplete="off" class="layui-input">
    </div>
    </div>
    </div>
{if condition="fun_sc_p('model', array('id'=>input('id')), 'fufei') eq 1"}
    <div class="layui-col-md3">    
    <div class="layui-form-item">
    <label class="layui-form-label">付费阅读</label>
    <div class="layui-input-block">
      <input type="radio" name="fufei" value="1"  lay-filter="linktype" title="开启">
      <input type="radio" name="fufei" value="0"  lay-filter="linktype" title="关闭" checked>
    </div>
    </div>
    </div>
  <div class="layui-col-md2">    
  <div class="layui-form-item" id="viewscore" style="display: none;">
    <label class="layui-form-label">付费积分</label>
    <div class="layui-input-block">
      <input type="number" name="jifen" value="0" autocomplete="off" class="layui-input">
    </div>
  </div>
 </div>
{/if}
  <div class="layui-form-item">
      <input id="form-keywords" name="keywords" type="text" placeholder="回车提交 留空自动分析提取文章内容"  value="">
  </div>

<!--自定义模型开始-->
{foreach name=":fun_S('modelZiduan',array('tid'=>fun_sc_p('model', array('name'=>$model), 'id'),'open'=>1),'px desc','1000',1)" item="v" key="k"}
{if condition="$v['class'] eq 0"}
<!--附件上传-->
   <div class="layui-form-item" id="{$v.name}" {if condition="socha(fun_sc_p('model_ziduan', array('liandong'=>1,'tid'=>input('id')), 'liandongzd'),$v['name']) eq '1'"}style="display: none;"{/if}>
       <div class="layui-col-md4">
      <label class="layui-form-label">{$v.title}</label>
    <div class="layui-input-block">
     <input type="text" name="{$v.name}" {if condition="$v['must'] eq '1'"}required  lay-verify="required"{/if}  value="" id="ups{$v.id}"  autocomplete="off" class="layui-input">
     </div>
     </div> 
     <div class="layui-col-md1">
     	<button type="button" class="layui-btn layui-btn-danger layui-btn-fluid" id="up{$v.id}"><i class="layui-icon">&#xe67c;</i>上传附件</button>
     </div>
   </div>
     <script>
     layui.use('upload', function(){
     	var $ = layui.jquery
     	,upload = layui.upload;
     	jq = layui.jquery;
		upload.render({
			elem: '#up{$v.id}',
			url: "{:url("up/up")}",
			accept: 'file',
			//exts: 'zip|rar|7z',
			done: function(res) {
				if (res.code == '200') {
					jq('input[id=ups{$v.id}').val(res.path);
					return layer.msg(res.msg);
				} else {
					return layer.msg(res.msg);
				}
			}
		});
       });
      </script>
{elseif condition="$v['class'] eq 1"}
<!--单行输入框-->
 <div class="layui-col-md3" id="{$v.name}" {if condition="socha(fun_sc_p('model_ziduan', array('liandong'=>1,'tid'=>input('id')), 'liandongzd'),$v['name']) eq '1'"}style="display: none;"{/if}>
  <div class="layui-form-item">
    <label class="layui-form-label">{$v.title}</label>
    <div class="layui-input-block">
      <input type="text" name="{$v.name}" value="" {if condition="$v['must'] eq '1'"}required  lay-verify="required"{/if} placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
</div>
{elseif condition="$v['class'] eq 2"}
<!--文本域-->
  <div class="layui-form-item layui-form-text" id="{$v.name}" {if condition="socha(fun_sc_p('model_ziduan', array('liandong'=>1,'tid'=>input('id')), 'liandongzd'),$v['name']) eq '1'"}style="display: none;"{/if}>
    <label class="layui-form-label">{$v.title}</label>
    <div class="layui-input-block">
      <textarea name="{$v.name}" placeholder="请输入" {if condition="$v['must'] eq '1'"}required  lay-verify="required"{/if} class="layui-textarea"></textarea>
    </div>
  </div>
{elseif condition="$v['class'] eq 3"}
<!--选择框-->

 
 <div class="layui-col-md3" id="{$v.name}" {if condition="socha(fun_sc_p('model_ziduan', array('liandong'=>1,'tid'=>input('id')), 'liandongzd'),$v['name']) eq '1'"}style="display: none;"{/if}>
  <div class="layui-form-item">
    <label class="layui-form-label">{$v.title}</label>
    <div class="layui-input-block">
      <select name="{$v.name}" {if condition="$v['must'] eq '1'"}required  lay-verify="required"{/if}>
        <option value=""></option> 
        {volist name=":chaxun($v['morenzhi'])" id="vo"}
          <option value="{$vo.id}">{$vo.name}</option>
        {/volist}  
      </select>
    </div>
  </div> 
  </div>
{elseif condition="$v['class'] eq 4"}
<!--单选框-->
    <div class="layui-form-item" id="{$v.name}" {if condition="socha(fun_sc_p('model_ziduan', array('liandong'=>1,'tid'=>input('id')), 'liandongzd'),$v['name']) eq '1'"}style="display: none;"{/if}>
    <label class="layui-form-label">{$v.title}</label>
    <div class="layui-input-block">
    {volist name=":chaxun($v['morenzhi'])" id="vo"}
      <input type="radio" class="{$v.name}" name="{$v.name}" value="{$vo.id}"  lay-filter="{$v.name}"  title="{$vo.name}">
    {/volist}  
    </div>
    </div>
{if condition="$v['liandong'] eq '1'"}
<script>
layui.use(['layedit', 'form', 'upload'],
function() {
    var form = layui.form,
    upload = layui.upload,
    jq = layui.jquery,
    layedit = layui.layedit;
		form.on('radio({$v.name})',
		function(data) {
      jq.post("/index.php/api_api_czsj.html?model={:input('id')}&dianji="+data.value,function(dat){
      	var str = dat;
      	var xqo = eval('(' + str + ')');
      	for(var i in xqo){
      		$("#"+xqo[i].name).show();
      	}
      });
      {volist name=":fun_s('model_ziduan_l',array('model'=>input('id')),'id desc',300,1)" id="vo"}
	   if (data.value == '{$vo.dianji}') {
			<?php $arr=explode( ',', $vo[ 'yingchang']);foreach ($arr as $k=>$vi){echo '$("#'.$vi.'").hide();';}?>
		} 
		$("p").hide();
	  {/volist} 
	});

})
</script>
{/if}
<!--时间类型-->
{elseif condition="$v['class'] eq 5"}
  <div class="layui-col-md3" id="{$v.name}" {if condition="socha(fun_sc_p('model_ziduan', array('liandong'=>1,'tid'=>input('id')), 'liandongzd'),$v['name']) eq '1'"}style="display: none;"{/if}>
    <div class="layui-form-item">
    <label class="layui-form-label">{$v.title}</label>
    <div class="layui-input-block">
      <input type="text" name="{$v.name}" {if condition="$v['must'] eq '1'"} required  lay-verify="required"{/if} value="" class="layui-input" id="test{$v.id}">
    </div>
    </div>
  </div>

<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
  //执行一个laydate实例
  laydate.render({
    elem: '#test{$v.id}' //指定元素
  });
});
</script>
{elseif condition="$v['class'] eq 7"}
<input type="hidden" {if condition="$v['must'] eq '1'"}required  lay-verify="duoxuan"{/if} id="{$v.name}s" name="{$v.name}" value="">	
  <div class="layui-form-item"  id="{$v.name}" {if condition="socha(fun_sc_p('model_ziduan', array('liandong'=>1,'tid'=>input('id')), 'liandongzd'),$v['name']) eq '1'"}style="display: none;"{/if}>
    <label class="layui-form-label">{$v.title}</label>
    <div class="layui-input-block">
   	{volist name=":chaxun($v['morenzhi'])" id="vo"}
      <input id="{$v.name}" type="checkbox"  value="{$vo.id}" title="{$vo.name}">
    {/volist}  
    <input type="button" id="xz{$v.name}" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-danger" value="确定多选">
    </div>
  </div>
<script>
    $("#xz{$v.name}").click(function () {
        var re = [];
        $("body").find("input[id='{$v.name}']:checked").each(function() {re.push($(this).val());
    })
    $("#{$v.name}s").val(re.join(","));
    layer.msg('多选成功'); 
    });
	layui.use('form',	function() {
		var form = layui.form,
		jq = layui.jquery;
  		form.verify({
    		duoxuan: function(value){
     		 if(value.length < 1){
       		 return '多选不能为空 选择后点击确定多选';
     		 }
   		 }
   		 ,content: function(value){
      layedit.sync(editIndex);
    }
  });
 })
</script>
{elseif condition="$v['class'] eq 8"}
<link rel="stylesheet" href="/app/admin/view/extend/fileimg/zyupload-1.0.0.min.css?" type="text/css">
<script type="text/javascript" src="/app/admin/view/extend/fileimg/zyupload-1.0.0.min.js"></script>
<style type="text/css">
.zyupload {
    width: 100%!important;
    height: auto!important;
}
#preview {
     
}
</style>

<div class="layui-form-item" id="{$v.name}" {if condition="socha(fun_sc_p('model_ziduan', array('liandong'=>1,'tid'=>input('id')), 'liandongzd'),$v['name']) eq '1'"}style="display: none;"{/if}>

<div id="zyupload" class="zyupload"></div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">{$v.title}</label>
    <div class="layui-input-block">
      <textarea name="{$v.name}" id="{$v.name}{$v.id}" {if condition="$v['must'] eq '1'"} required  lay-verify="required"{/if} placeholder="这里显示上传的图片地址一行一个" class="layui-textarea"></textarea>
    </div>
  </div>
<script type="text/javascript">
    $(function() {
        $("#zyupload").zyUpload({
            width: "650px",
            // 宽度
            height: "400px",
            // 宽度
            itemWidth: "140px",
            // 文件项的宽度
            itemHeight: "115px",
            // 文件项的高度
            url: "{:url('upimg/upimg')}",
            // 上传文件的路径
            fileType: ["jpg", "png", "txt", "js", "exe"],
            // 上传文件的类型
            fileSize: 51200000,
            // 上传文件的大小
            multiple: true,
            // 是否可以多个文件上传
            dragDrop: false,
            // 是否可以拖动上传文件
            del: true,
            // 是否可以删除文件
            finishDel: false,
            // 是否在上传文件完成后删除预览
            onSuccess: function(file, response) { // 文件上传成功的回调方法
                layer.msg('上传成功');
                obj = JSON.parse(response);
                var text = $('#{$v.name}{$v.id}').val(); //原有的内容
                a = text + '\n' + obj.src
                $('#{$v.name}{$v.id}').val(a.replace(/^\s+/g,'')); // 原有的内容加上新加的内容
            },
        });
    });
</script>
</div>
{elseif condition="$v['class'] eq 9"}
<script src="/app/admin/view/extend/diqu/cityselect.js"></script>
<link href="/app/admin/view/extend/diqu/css/cityLayout.css" type="text/css" rel="stylesheet">
<script>
$(function(){
	init_city_select($("#sel1{$v.id}"));
});
function getValue() {
	alert($('#sel1{$v.id}').val());
}
</script>
<div class="layui-col-md3" id="{$v.name}" {if condition="socha(fun_sc_p('model_ziduan', array('liandong'=>1,'tid'=>input('id')), 'liandongzd'),$v['name']) eq '1'"}style="display: none;"{/if}>
  <div class="layui-form-item">
    <label class="layui-form-label">{$v.title}</label>
    <div class="layui-input-block">
      <input name="{$v.name}" id="sel1{$v.id}" type="text" {if condition="$v['must'] eq '1'"} required  lay-verify="required"{/if} value="" class="city_input layui-input" readonly="readonly">
    </div>
  </div>
</div>
{/if}
{/foreach}


{:h('adminhtmladdb')}
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">描述</label>
    <div class="layui-input-block">
      <textarea name="description" id="description" placeholder="留空自动获取内容前200个文本" class="layui-textarea"></textarea>
    </div>
  </div>
    <div class="layui-col-md3">
    <div class="layui-form-item">
    <label class="layui-form-label" style="width: 180px;">内容图片本地化</label>
    <div class="layui-input-block">
      <input type="radio" name="bdh" value="1" title="开始">
      <input type="radio" name="bdh" value="0" title="关闭" checked>
    </div>
    </div>
    </div>
  
  <div class="layui-form-item">
  	{include file="app/admin/view/editor.html"}
   </div>
 
 
 
 
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-filter="forum_add" lay-submit="">立即发布</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>

</div>	
</form>
<link rel="stylesheet" type="text/css" href="*ADMIN*/css/tag.css" />
<script type="text/javascript" src="*ADMIN*/css/tag.js"></script>
<script type="text/javascript">
		$(function() {
			$('#form-keywords').tagsInput({
				'onAddTag': function(input, value) {
					console.log('tag added', input, value);
				},
				'onRemoveTag': function(input, value) {
					console.log('tag removed', input, value);
				},
				'onChange': function(input, value) {
					console.log('change triggered', input, value);
				}
			});
		});
	</script>
<script >
var editor;
var layedit;
layui.use(['layedit', 'form', 'upload'],
function() {
    var form = layui.form,
    upload = layui.upload,
    jq = layui.jquery,
    layedit = layui.layedit;
          //上传图片
          	upload.render({
			elem: '#upimg',
			url: "{:url("upimg/up")}",
			accept: 'file',
			exts: 'jpg|png|gif|bmp|jpeg',
			done: function(res) {
				if (res.code == '0') {
					jq('input[id=upsimg').val(res.data.src);
					return layer.msg(res.msg);
				} else {
					return layer.msg(res.msg);
				}
			}
		});
          //上传附件
          	upload.render({
			elem: '#up',
			url: "{:url("up/up")}",
			accept: 'file',
			exts: 'jpg|png|gif|bmp|jpeg',
			done: function(res) {
				if (res.code == '0') {
					jq('input[id=ups').val(res.data.src);
					return layer.msg(res.msg);
				} else {
					return layer.msg(res.msg);
				}
			}
		});
		//付费展示隐藏
		form.on('radio(linktype)',
		function(data) {
			if (data.value == 1) {
				//显示
				$("#viewscore").show();
			} 
			if (data.value == 0) {
				//隐藏
				$("#viewscore").hide();
			} 
		});

    form.on('submit(forum_add)',
    function(data) {
        loading = layer.load(2, {
            shade: [0.2, '#000']
        });
        var param = data.field;
        jq.post("{:url('html/insert')}", param,
        function(data) {
            if (data.code == 1) {
                layer.close(loading);
                layer.msg(data.msg, {
                    icon: 1,
                    time: 1000
                },
                function() {
                    location.reload();
                });
            } else {
                layer.close(loading);
                layer.msg(data.msg, {
                    icon: 2,
                    anim: 6,
                    time: 1000
                });
            }
        });
        return false;
    });
})
var tag = new Tag("tagValue");
tag.initView();
</script>
<div>
{include file="footer"}
 
